import requests
import  execjs

cookies = {
    'OUTFOX_SEARCH_USER_ID_NCOO': '1630589594.0834453',
    'OUTFOX_SEARCH_USER_ID': '1214640989@116.236.99.42',
}

headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded',
    # 'Cookie': 'OUTFOX_SEARCH_USER_ID_NCOO=1630589594.0834453; OUTFOX_SEARCH_USER_ID=1214640989@116.236.99.42',
    'Origin': 'https://youdao.com',
    'Referer': 'https://youdao.com/',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-site',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36',
    'sec-ch-ua': '"Chromium";v="118", "Google Chrome";v="118", "Not=A?Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
}

params = {
    'doctype': 'json',
    'jsonversion': '4',
}

data = execjs.compile(open('有道翻译逆向JS.js','r',encoding='utf-8').read()).call('decryptData','英国')


print(data)
response = requests.post('https://dict.youdao.com/jsonapi_s', params=params, cookies=cookies, headers=headers, data=data).json()

for item in response:
    print(item)